package com.jh.paymentchannel.payment.alipay;

import com.jh.paymentchannel.payment.TradeStatus;

import java.math.BigDecimal;
import java.util.Map;

/**
 * @author Yichuan
 * @version 1.0
 */
public class AlipayPayResult {

    private String notifyTime;
    private String notifyType;
    private String notifyId;
    private String appId;
    private String charset;
    private String version;
    private String signType;
    private String sign;
    private String tradeNo;
    private String outTradeNo;
    private TradeStatus tradeStatus;
    private BigDecimal totalAmount;
    private BigDecimal receiptAmount;
    private String fundBillList;

    public AlipayPayResult() {
    }

    public String getNotifyTime() {
        return notifyTime;
    }

    public void setNotifyTime(String notifyTime) {
        this.notifyTime = notifyTime;
    }

    public String getNotifyType() {
        return notifyType;
    }

    public void setNotifyType(String notifyType) {
        this.notifyType = notifyType;
    }

    public String getNotifyId() {
        return notifyId;
    }

    public void setNotifyId(String notifyId) {
        this.notifyId = notifyId;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getCharset() {
        return charset;
    }

    public void setCharset(String charset) {
        this.charset = charset;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getSignType() {
        return signType;
    }

    public void setSignType(String signType) {
        this.signType = signType;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public String getTradeNo() {
        return tradeNo;
    }

    public void setTradeNo(String tradeNo) {
        this.tradeNo = tradeNo;
    }

    public String getOutTradeNo() {
        return outTradeNo;
    }

    public void setOutTradeNo(String outTradeNo) {
        this.outTradeNo = outTradeNo;
    }

    public TradeStatus getTradeStatus() {
        return tradeStatus;
    }

    public void setTradeStatus(TradeStatus tradeStatus) {
        this.tradeStatus = tradeStatus;
    }

    public BigDecimal getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(BigDecimal totalAmount) {
        this.totalAmount = totalAmount;
    }

    public BigDecimal getReceiptAmount() {
        return receiptAmount;
    }

    public void setReceiptAmount(BigDecimal receiptAmount) {
        this.receiptAmount = receiptAmount;
    }

    public String getFundBillList() {
        return fundBillList;
    }

    public void setFundBillList(String fundBillList) {
        this.fundBillList = fundBillList;
    }

    public static AlipayPayResult mapToObject(Map<String, String> params) {
        AlipayPayResult result = new AlipayPayResult();
        result.setNotifyTime(params.get("notify_time"));
        result.setNotifyType(params.get("notify_type"));
        result.setNotifyId(params.get("notify_id"));
        result.setAppId(params.get("app_id"));
        result.setCharset(params.get("charset"));
        result.setVersion(params.get("version"));
        result.setSignType(params.get("sign_type"));
        result.setSign(params.get("sign"));
        result.setTradeNo(params.get("trade_no"));
        result.setOutTradeNo(params.get("out_trade_no"));
        String statusCode = params.get("trade_status");
        result.setTradeStatus(TradeStatus.of(statusCode));
        String total = params.get("total_amount");
        result.setTotalAmount(new BigDecimal(total));
        String receipt = params.get("receipt_amount");
        result.setReceiptAmount(new BigDecimal(receipt));
        result.setFundBillList(params.get("fund_bill_list"));
        return result;
    }
}
